#include<bits/stdc++.h>
using namespace std;
int n,m,L,V;//n, m, L, V ,分别表示车辆数量、测速仪数量、主干道长度和道路限速。
struct node{
    int d,v,a;//从主干道上距离最南端 d i 的位置驶入,以 v i 的初速度和 a i 的加速度做匀加速运动向北行驶
};
vector<node>c;
node inp;
int tra[100009];
map<int,int>ma;
int aans;
int ipd,ipv,ipa;
double countv(int lc,int a,int v){
    return sqrt(double(double(v*v)+double(2*a*lc)));
}
double countsmax(int a,int v){//a<0
    return sqrt(double(double(v*v)/(0-2*double(a))));
}
void CheckOverVn(node now){
    int lc=L-now.d;
    if(now.a==0 and now.v<=V){
        return;
    }
    if(now.a==0 and now.v>=V){
        int minn=0;
        while(minn<m and tra[minn]<now.d){
            minn++;
        }
        if(minn==m){
            return;
        }
        bool flag=false;
        for(int i = minn;i<=m;i++){
            ma[tra[i]]++;
                if(flag==false){
                    flag=true;
                    aans++;
                }
        }
        return;
    }
    else if(now.a>0){
        int minn=0;
        while(minn<m and tra[minn]<now.d){
            minn++;
        }
        if(minn==m){
            return;
        }

        bool flag=false;
        for(int i = minn;i<m;i++){
            lc=tra[i]-now.d;
            //cout<<now.d<<" "<<lc<<" "<<countv(lc,now.a,now.v)<<endl;
            if(countv(lc,now.a,now.v)>V){
                    //cout<<now.d<<" "<<lc<<" "<<countv(lc,now.a,now.v)<<endl;
                ma[tra[i]]++;
                if(flag==false){
                    flag=true;
                    aans++;
                }
            }
        }
    }

    else if(now.a<0){
        int minn=0,maxx=-1;
        double tmp=countsmax(now.a,now.v)+double(now.d);
        while(minn<m and tra[minn]<now.d){
            minn++;
        }
         if(tmp>L){
            maxx=m-1;
         }else{
            while(maxx>=0 and tra[maxx]>tmp){
                maxx--;
            }
         }
         if(maxx<minn){
            return;
         }

         bool flag=false;
        for(int i = minn;i<=maxx;i++){
            lc=tra[i]-now.d;
            //cout<<now.d<<" "<<lc<<" "<<countv(lc,now.a,now.v)<<endl;
            if(countv(lc,now.a,now.v)>V){
                ma[tra[i]]++;
                if(flag==false){
                    flag=true;
                    aans++;
                }
            }
        }
    }
}
int main(){
    //priority_queue(int,vector<int>,greater<int>)q;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("a.in","r",stdin);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    for(int wq=1;wq<=t;wq++){
        cin>>n>>m>>L>>V;
        c.clear();
        ma.clear();
        memset(tra,0,sizeof(tra));
        aans=0;
        //
        for(int i = 1;i<=n;i++){
            cin>>ipd>>ipv>>ipa;
            inp.d=ipd;
            inp.v=ipv;
            inp.a=ipa;
            c.push_back(inp);
        }
        for(int i = 0;i<m;i++){
            int tmp;
            cin>>tra[i];
        }
        sort(tra,tra+m);
        for(int i = 0;i<n;i++){
            CheckOverVn(c[i]);

        }
        cout<<aans<<" ";
        int bans=0;
        for(int i = 0;i<m;i++){
            if(ma[tra[i]]==n){
                bans++;
            }
        }
        cout<<bans<<endl;
    }
    return 0;
}
